package tmproject.hlhj.fhp.cartrans

import android.app.Application
import com.lzy.okgo.OkGo
import com.lzy.okgo.cookie.CookieJarImpl
import com.lzy.okgo.cookie.store.MemoryCookieStore
import com.lzy.okgo.interceptor.HttpLoggingInterceptor
import com.tencent.bugly.Bugly
import com.tencent.bugly.beta.Beta
import okhttp3.OkHttpClient
import tmproject.hlhj.fhp.cartrans.activitys.HomeAty
import tmproject.hlhj.fhp.cartrans.activitys.UpdataAty
import tmproject.hlhj.fhp.cartrans.utils.ToastUtils
import java.lang.ref.WeakReference
import java.util.concurrent.TimeUnit
import java.util.logging.Level

/**

 */
class MyApp :Application() {
    override fun onCreate() {
        super.onCreate()
        Beta.autoCheckUpgrade=true
//        Beta.canShowUpgradeActs.add(HomeAty::class.java)
        Bugly.init(applicationContext, "0a86e77d88", false);
        ToastUtils.c= applicationContext
        /*Okgo设置*/
        OkGo.getInstance().init(this)
        val builder = OkHttpClient.Builder()
        val loggingInterceptor = HttpLoggingInterceptor("OkGo")
        loggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY)
        loggingInterceptor.setColorLevel(Level.INFO)
        builder.readTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS)
        builder.writeTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS)
        builder.connectTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS)
        builder.cookieJar(CookieJarImpl(MemoryCookieStore()))
        builder.addInterceptor(loggingInterceptor)
        OkGo.getInstance().setOkHttpClient(builder.build())
//        ---------------------------------------
    }
}